package day04;

import java.util.Scanner;

public class ChickenAndRabbit {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入总数");
        int totle = sc.nextInt();
        System.out.println("输入特征点总数");
        int spPoint = sc.nextInt();
        System.out.println("输入A单体特征数");
        int aSp = sc.nextInt();
        System.out.println("输入B单体特征数");
        int bSp = sc.nextInt();
        if (aSp<bSp) {
            int aNumber = Chicken(totle, spPoint, aSp, bSp);
            System.out.println("A有" + aNumber + "只" + "B有" + (totle - aNumber) + "只");
        }
        else {
            int bNumber = Rabbit(totle, spPoint, aSp, bSp);
            System.out.println("A有" + (totle - bNumber) + "只" + "B有" +  bNumber + "只");
        }

    }
    public  static int Chicken(int x,int y,int a,int b){
        return (y-b*x)/(a-b);//运用求根公式求解 （x-?）*b+a*？=y > ？= (y-b*x)/(a-b) //(a>b）

    }
    public  static int Rabbit (int x,int y,int a,int b){
        return (y-a*x)/(b-a);//运用求根公式求解 （x-?）*a+b*？=y > ？= (y-a*x)/(b-a) //(b>a）

    }

}
